using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ServerLeftItem : MonoBehaviour
{
    //自己的Button组件
    public Button buttonSelf;
    //自己的文本组件
    public TextMeshProUGUI textSefl;
    private int beginId;
    private int endId;
    // //声明一个希望监听的事件对象
    // EventTrigger.Entry entry = new EventTrigger.Entry();
    // //关联对应的EventTrigger组件
    // public EventTrigger et;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        // //声明事件监听的类型
        // entry.eventID = EventTriggerType.Select;
        // //为监听函数添加方法
        // entry.callback.AddListener((data) =>
        // {
        //     //字体颜色变成白色（用于表示选中状态）
        //     textSefl.color = Color.white;
        // });
        //将编辑好的监听事件添加到EventTrigger当中
        // et.triggers.Add(entry);
        buttonSelf.onClick.AddListener(() =>
        {
            //告诉选服面板改变右侧显示的服务器
            ChooseServerPanel csp = UIManager.Instance.GetPanel<ChooseServerPanel>();
            csp.Updatepanel(beginId, endId);
        });
    }
    public void whenSelect(BaseEventData a)
    {
        // 字体颜色变成白色（用于表示选中状态）
        textSefl.color = Color.white;
    }
    public void notSelect(BaseEventData a)
    {
        textSefl.color = new Color(0.7215686f, 0.6196079f, 0.5843138f);
    }
    public void InitInfo(int beginId, int endId)
    {
        //记录当前的按钮的区间值
        this.beginId = beginId;
        this.endId = endId;
        //将文本设置为设定的区间值
        textSefl.text = beginId + "-" + endId + "区";
    }
}
